import 'dart:convert';
import 'package:get/get.dart';

import '../common/sharedPreferences_helper.dart';
import '../common/api_service.dart';
import '../model/emotion_model.dart';

class GlobalConfigService extends GetxService {
  getEmojiConfig() {
    ApiService().getEmojiConfig((emotionList) async {
      List<EmotionModel> list = emotionList as List<EmotionModel>;
      List<Map<String, dynamic>> emotionJsonList = list.map((emotion) => emotion.toJson()).toList();
      String jsonString = jsonEncode(emotionJsonList);
      await SharedPreferencesHelper.setString("emotionList", jsonString);
    }, () {});
  }
}
